function [t t_bd options] = ex33_AnalyticalTraction(x,y,s_xx,s_yy,s_xy,options,id)
%function [t t_bd options] = ex33_AnalyticalTraction(x,y,s_xx,s_yy,s_xy,options,id)
% This function computes the traction on the boundaries
% x,y = nodal coordinates
% [s_xx s_xy; s_xy s_yy] stress tensor
%

eps   = 1.0e-5;
t_bd  = 0;
sigma = [s_xx s_xy; s_xy s_yy];
t     = [0 0];
L     = options.L;

if abs(y-0)<eps
    nx          = 0;
    ny          = -1;
    options.bd1 = [options.bd1 id];
    n           = [nx ; ny];
    t           = t + (sigma * n)';
    t_bd        = 1;
end

if abs(x-L)<eps
    nx          = 1;
    ny          = 0;
    options.bd2 = [options.bd2 id];
    n           = [nx ; ny];
    t           = t + (sigma * n)';
    t_bd        = 1;
end

if abs(y-L)<eps
    nx          = 0;
    ny          = 1;
    options.bd3 = [options.bd3 id];
    n           = [nx ; ny];
    t           = t + (sigma * n)';
    t_bd        = 1;
end

if abs(x-0)<eps
    nx          = -1;
    ny          = 0;
    options.bd4 = [options.bd4 id];
    n           = [nx ; ny];
    t           = t + (sigma * n)';
    t_bd        = 1;
end


